<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div id="test_add" style="padding:10px 10px 10px 10px">
	<form id="testAddForm" method="post">
		<input type="hidden" name="id" value="${test.id }"/>
		<input type="hidden" name="text" value="${test.name }"/>
	    <table class="tm-tableAttr">
		    <tr class="tm-tableAttrSub">
		        <th colspan="14">测试用例</th>
		    </tr>
	        <tr>
	            <th>用例编号</th>
	            <td><input class="textbox" type="text" id="caseNo" name="caseNo"></input></td>
	        </tr>
	        <tr>
	    	
	       	<tr>
	    	<th>已具备自动化用例</th>
		    	<td><input class="textbox" type="text" id="autoUseCase" name="autoUseCase"></input></td>
		    </tr>
		    <tr>
	    	<th>筛选/修改/添加</th>
		    	<td>
					<select class="combo .combo-text combo-arrow-hover" style="width:171px;" name="fma">
						<option value="">请选择</option>
						<option value="筛选">筛选</option>
	            		<option value="修改">修改</option>
	            		<option value="添加">添加</option>
	            	</select>
				</td>
		    </tr>
		    <tr>
			<th>自动化状态</th>
				<td>
					<select class="combo .combo-text combo-arrow-hover" style="width:171px;" name="autoStatus">
						<option value="">请选择</option>
						<option value="不可自动化">不可自动化</option>
	            		<option value="可自动化，已调通">可自动化，已调通</option>
	            		<option value="可自动化，待集成测试提供">可自动化，待集成测试提供</option>
	            	</select>
				</td>
			</tr>
	    </table>
	</form>
	<div style="padding:5px">
	    <a href="javascript:void(0)" class="button" onclick="submitForm()">提交</a>
	    <a href="javascript:void(0)" class="button" onclick="clearForm()">重置</a>
	</div>
</div>
<script type="text/javascript">
	$(function(){
	});
	
function submitForm(){
	var caseNo = $('#caseNo').val();
	if(caseNo==null || caseNo.length==0) {
		$.messager.alert('提示','用例编号不能为空!');
		return;
	}
	if(caseNo.length>=10) {
		$.messager.alert('提示','用例编号长度不能超过10位!');
		return;
	}
	$.get("/test/isdup",{caseNo:caseNo}, function(data) {
		if(data.data!=null) {
			$.messager.alert('提示','用例编号已经存在！');
			$('#caseNo').val('');
			return;
		} else {
			$.post("/test/save",$("#testAddForm").serialize(), function(data){
				if(data.status==200){
					var id = data.data.id;
					var no = data.data.caseNo;
					var node = $('#testCategory').tree('getSelected');
					$('#testCategory').tree("update",{
           				target : node.target,
           				caseNo : data.data.caseNo
           			});
					$.ajax({
						url:'/test/querybyno',
						dataType:'html',
						data:{
							id:id,
							caseNo:no
						},
						success:function(data) {
							$('#test_add').empty();
							$('#test_add').append(data);
						}
					})
				}
			});
		}
	})
	
}
function clearForm(){
	$('#testAddForm').form('reset');
}
</script>
